
<template>

  <center>
    <div  >

      <!-- 正文 注册注册注册注册注册注册注册注册注册注册注册注注册注册注册注册注册注注册注册注册注册注册注-->
<!--      <img src="../../static/小狗.jpg"  width="200px" height="100px">  <br>-->

      <el-form ref="loginForm" label-width="80px"  >


        <el-form-item label="用户名">
          <input type="text" placeholder="用户名" v-model="zcForm.username">  <br>
        </el-form-item>

        <el-form-item label="手机号">
          <input type="text" placeholder="手机号" v-model="zcForm.mobile" >  <br>
        </el-form-item>



        <el-form-item label="特殊资源">
          <el-radio-group v-model="zcForm.apartmentOperatorType">
            <el-radio label="1"></el-radio>
            <el-radio label="2"></el-radio>
          </el-radio-group>
        </el-form-item>



        <!--    密码框的显示  1-->
        <!--            密码框的显示之辅助文本框-->
        <input type="text" v-if="pwdType" v-model="zcForm.password">
        <input type="password" placeholder="请输入密码" v-model="zcForm.password" v-else>

        <img :src="seen ? unseenImg : seenImg" @click="changeType()" width="30px"height="30px"/>  <br>



        <!--    密码框的显示  2-->
        <!--            密码框的显示之辅助文本框-->
        <input type="text" v-if="pwdType2" v-model="zcForm.eyetxt2" >
        <input type="password" placeholder="请再次输入确认密码" v-model="zcForm.eyetxt2" v-else>

        <img :src="seen2 ? unseenImg : seenImg" @click="changeType2()"  width="30px"height="30px"/>



          <el-input v-model="zcForm.mobileCode" /><a @click="getCode">获取验证码</a>






        <el-form-item>
          <el-checkbox label="已经同意"  ></el-checkbox>
        </el-form-item>



        <el-form-item>
          <el-button type="primary" @click="add">注册</el-button>
        </el-form-item>

      </el-form>

    </div>
  </center>
</template>

<script>

export default {
  name: 'Login',
  data() {
    return {
      zcForm: {
        username: '',
        mobile:'',
        apartmentOperatorType:'1',
        password:""
      },
      seen:'',
      unseenImg:require("../../img/展密码.png"),//看不见
      seenImg :require("../../img/藏密码.png"),//看得见密码

      pwdType:false, //此时文本框隐藏，显示密码框

      seen2:'',
      eyetxt2:"",
      pwdType2:false, //此时文本框隐藏，显示密码框
      radio:'1',
      radio2:'2',
      username: '',

      usertel:'',
      codeUrl: ''

    }
  },
  created() {

  },
  methods: {
    login() {

      var _this = this
      console.log(_this.$store.state)
      this.axios
        .post('/login', {
          username: this.loginForm.username,
          password: this.loginForm.password
        })
        .then(successResponse => {
          if (successResponse.data.code === 200) {

            this.$router.push({path: '/completion', query: {selected: "2"}});

          }
        })

    },//login  end
    login2(){
      var mobile=this.zcForm.mobile
      this.$router.push({path: '/completion', query: {mobile: mobile}});
    },


    //密码的显示隐藏
    changeType:function(){
      this.seen = !this.seen;//小眼睛的变化
      this.pwdType=!this.pwdType;//跟着小眼睛变化，密码框隐藏显示文本框，内容就显示了
    },
    changeType2:function(){
      this.seen2 = !this.seen2;//小眼睛的变化
      this.pwdType2=!this.pwdType2;//跟着小眼睛变化，密码框隐藏显示文本框，内容就显示了
    },
    add() {
      this.axios.post('http://localhost:9999/system-management/sys/register', this.zcForm
      ).then((response) => {


        if (response.data.code == 3001) {
          alert('号码已存在')
          return
          // eslint-disable-next-line eqeqeq
        } else if (response.data.code == 3004) {
          alert('验证码错误')
          return
          // eslint-disable-next-line eqeqeq
        }
          console.log(response.data.obj)
          console.log(typeof response.data.obj)
          alert('注册成功')

          var mobile = this.zcForm.mobile
          this.$router.push({path: '/MoreMessage', query: {mobile: mobile}});


      })


    },
    getCode() {
      // eslint-disable-next-line eqeqeq
      // if (this.registerForm.mobile == null) {
      //   alert('请输入手机号')
      //   return
      // }
      this.axios.post('http://localhost:9999/system-management/tbSmsRecords/sendSms', this.zcForm).then((response) => {
        console.log(response.data)
        // eslint-disable-next-line eqeqeq
        if (response.data.code == 3001) {
          alert('号码已存在')
          return
          // eslint-disable-next-line eqeqeq
        } else if (response.data.code == 3002) {
          alert('验证短信未超过两分钟')
          return
        }
      })
    },



  }
}

</script>


<style>


.el-input2 {
  width: 200px;

}



</style>
